<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>管理员管理页面</title>
<%
	pageContext.setAttribute("APP_PATH", request.getContextPath());
%>
<script src="${APP_PATH}/static/js/jquery-3.1.1.min.js"></script>
<link rel="stylesheet"
	href="${APP_PATH}/static/bootstrap-3.4.1-dist/css/bootstrap.min.css">
<script
	src="${APP_PATH}/static/bootstrap-3.4.1-dist/js/bootstrap.min.js"></script>
</head>
<body>
	<!-- 搭建显示页面 -->
	<div class="container">
		<!-- 标题行 -->
		<div class="row">
			<div class="col-xs-12">
				<h1>管理员页面</h1>
			</div>
		</div>
		<!-- 按钮 -->
		<!-- <div class="row">
        <div class="col-md-4 col-md-offset-8">
            <button class="btn btn-primary">新增</button>
            <button class="btn btn-danger">删除</button>
        </div>
    </div> -->
		<!-- 显示表格数据 -->
		<div class="dropdown col-md-4">
			<button class="btn btn-default dropdown-toggle" type="button"
				id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true"
				aria-expanded="true">
				具体功能 <span class="caret"></span>
			</button>
			<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
				<li><a href="/currdesign/order/selectAll">订单管理</a></li>
				<li><a href="/currdesign/user/selectAll">用户管理</a></li>
				<li><a href="/currdesign/car/manager-cargetall">汽车管理</a></li>
			</ul>
		</div>
		<div class="row">
			<div class="col-md-12">

				<!-- 按钮 -->
				<div class="row">
					<div class="col-md-4 col-md-offset-8">
						<!-- <button class="btn btn-primary" id="insert_btn">新增</button> -->
						<button class="btn btn-primary" data-toggle="modal"
							data-target="#myModal">
							<span class="glyphicon glyphicon-plus">增加管理</span>
						</button>
						<!-- 增加——模态框 -->
						<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
							aria-labelledby="myModalLabel" aria-hidden="true">
							<div class="modal-dialog">
								<div class="modal-content">
									<div class="modal-header">
										<button type="button" class="close" data-dismiss="modal"
											aria-hidden="true">×</button>
										<h4 class="modal-title" id="myModalLabel">新增管理员</h4>
									</div>
									<div class="modal-body">
										<!-- form表单 -->
										<form action="${APP_PATH}/manager/insertManager" method="post">
											管理员密码：<input type="text" name="password" placeholder="管理员密码"
												required="required"><br> <br> 管理员功能：<input
												type="text" name="function" placeholder="管理员功能"
												required="required"><br> <br> <input
												type="submit" class="btn btn-default" value="提交" />
										</form>
									</div>
									<div class="modal-footer">
										<button type="button" class="btn btn-default"
											data-dismiss="modal">关闭</button>
									</div>
								</div>
							</div>
						</div>





						<!-- 管理模块 -->
						<!-- <a href="/currdesign/order/selectAll"><button type="button"
								class="btn btn btn-info">订单页面</button></a> <a
							href="/currdesign/user/selectAll"><button type="button"
								class="btn btn btn-info">用户页面</button></a> <a
							href="/currdesign/car/manager-cargetall"><button
								type="button" class="btn btn btn-info">汽车页面</button></a>
 -->


					</div>
				</div>

				<table class="table table-hover">
					<tr>
						<th>id</th>
						<th>password</th>
						<th>function</th>
						<th>操作</th>
					</tr>
					<c:forEach items="${pageInfo.list }" var="manager">
						<tr>
							<th>${manager.id }</th>
							<th>${manager.password }</th>
							<th>${manager.function}</th>
							<th>
								<button class="btn btn-primary btn-sm" data-toggle="modal"
									data-target="#myEditModal" onclick="Values(${manager.id})">
									<span class="glyphicon glyphicon-pencil" aria-hidden="true">编辑</span>
								</button>
								<div class="modal fade" id="myEditModal" tabindex="-1"
									role="dialog">
									<div class="modal-dialog" role="document">
										<div class="modal-content">
											<div class="modal-header">
												<button type="button" class="close" data-dismiss="modal"
													aria-label="Close">
													<span aria-hidden="true">&times;</span>
												</button>
												<h4 class="modal-title">修改信息</h4>
											</div>
											<div class="modal-body">
												<form action="${APP_PATH}/manager/editManager" method="post">
													<input type="hidden" id="id1" name="id" value="">
													管理员密码：<input type="text" name="password"
														placeholder="管理员密码" required="required"><br>
													<br> 管理员功能：<input type="text" name="function"
														placeholder="管理员功能" required="required"><br>
													<br> <input type="submit" value="提交"
														class="btn btn-default">
												</form>
											</div>
											<div class="modal-footer">
												<button type="button" class="btn btn-default"
													data-dismiss="modal">关闭</button>
											</div>
										</div>
										<!-- /.modal-content -->
									</div>
									<!-- /.modal-dialog -->
								</div>


								<button class="btn btn-danger btn-sm" data-toggle="modal"
									data-target="#myDeleteModal" onclick="Values(${manager.id})">
									<span class="glyphicon glyphicon-trash" aria-hidden="true">删除</span>
								</button>

								<div class="modal fade" id="myDeleteModal" tabindex="-1"
									role="dialog">
									<div class="modal-dialog" role="document">
										<div class="modal-content">
											<div class="modal-header">
												<button type="button" class="close" data-dismiss="modal"
													aria-label="Close">
													<span aria-hidden="true">&times;</span>
												</button>
												<h4 class="modal-title">删除信息</h4>
											</div>
											<div class="modal-body">
												<form action="${APP_PATH}/manager/deleteManager"
													method="post">
													<input type="hidden" id="id2" name="id" value=""> <input
														type="submit" value="删除" class="btn btn-default">
												</form>
											</div>
											<div class="modal-footer">
												<button type="button" class="btn btn-default"
													data-dismiss="modal">关闭</button>
											</div>
										</div>
										<!-- /.modal-content -->
									</div>
									<!-- /.modal-dialog -->
								</div>
							</th>
						</tr>
					</c:forEach>
				</table>
			</div>
		</div>
		<!-- 分页信息 -->
		<div class="row">
			<!-- 分页文字信息 -->
			<div class="col-md-6">当前${pageInfo.pageNum }页,总${pageInfo.pages }页,总${pageInfo.total }条记录
			</div>
			<!-- 分页条信息 -->
			<div class="col-md-6">
				<nav aria-label="Page navigation">
					<ul class="pagination">
						<li><a href="${APP_PATH }/manager/selectAll?pn=1">首页</a></li>
						<c:if test="${pageInfo.hasPreviousPage }">
							<li><a
								href="${APP_PATH }/manager/selectAll?pn=${pageInfo.pageNum-1}"
								aria-label="Previous"> <span aria-hidden="true">&laquo;</span>
							</a></li>
						</c:if>
						<c:forEach items="${pageInfo.navigatepageNums }" var="page_Num">
							<c:if test="${page_Num == pageInfo.pageNum }">
								<li class="active"><a href="#">${page_Num }</a></li>
							</c:if>
							<c:if test="${page_Num != pageInfo.pageNum }">
								<li><a href="${APP_PATH }/manager/selectAll?pn=${page_Num}">${page_Num}</a></li>
							</c:if>
						</c:forEach>
						<c:if test="${pageInfo.hasNextPage }">
							<li><a
								href="${APP_PATH }/manager/selectAll?pn=${pageInfo.pageNum+1}"
								aria-label="Next"> <span aria-hidden="true">&raquo;</span>
							</a></li>
						</c:if>

						<li><a
							href="${APP_PATH }/manager/selectAll?pn=${pageInfo.pages}">末页</a></li>
					</ul>
				</nav>
			</div>
		</div>
	</div>
	<script type="text/javascript">
    /*发送下载订单请求*/
    function downloadPass(license) {
        if (confirm('确认下载？')) {
            $.ajax({
                url: "${APP_PATH}/manager1/downloadlicense",
                data: {"license": license},
                type: "POST",
                // success: function (data) {
                //     if (data == "OK") {
                //         alert("下载成功");
                //         window.location.reload();
                //     } else {
                //         alert("下载失败");
                //         window.location.reload();
                //     }
                // }
            })
            ;
        }
    }

   /*  $("#myEditModal").modal("hide");
    $("#myDeleteModal").modal("hide"); */

    function Values(id) {
        $("#id1").val(id);
        $("#id2").val(id);
    }

</script>
</body>
</html>